#include "TraceFunction.h"
#include "SimpleLog.h"

namespace catan
{
	static const tstring ENTER_STRING = _T("---------- Enter ----------");
	static const tstring LEAVE_STRING = _T("---------- Leave ----------");

	TraceFunction::TraceFunction(const tstring& funcName, const tstring& filename, int line)
		: mFuncName(funcName)
		, mFilename(filename)
		, mLine(line)
		, mLog(SimpleLog::Instance())
		, mCanOutput(mLog.CanOutputPriorityLevel(PriorityLevel::Function))
	{
		if (mCanOutput)
		{
			mLog.OutputLog(PriorityLevel::Function, ENTER_STRING, mFuncName, mFilename, mLine);
		}
	}

	TraceFunction::~TraceFunction()
	{
		if (mCanOutput)
		{
			mLog.OutputLog(PriorityLevel::Function, LEAVE_STRING, mFuncName, mFilename, mLine);
		}
	}
}
